<?php

namespace App\Http\Controllers\OA;

use App\Http\Controllers\Controller;
use App\Http\Controllers\Logic\ZhiDuLogic;
use Illuminate\Http\Request;

class ZhiDuController extends Controller
{
    public function getList(Request $request)
    {
        try{
            $rules = [
                'page'=>'required|numeric|min:1',
                'page_size'=>'required|numeric|min:10',
                'header'=>'string|present|nullable',
                'username'=>'string|present|nullable',
            ];
            $this->verify($request->all(),$rules);
            $list = (new ZhiDuLogic())->getList($request->all());
            ret_json('ok','ok',$list);
        }catch (\Exception $e){
            ret_json('err',$e->getMessage());
        }
    }

    public function addZhidu(Request $request)
    {
        try{
            $rules = [
                'header'=>'string|required',
                'content'=>'string|required',
                'id'=>'sometimes|numeric'
            ];
            $params = $this->mergeRequest($request);
            $this->verify($params,$rules);
            $list = (new ZhiDuLogic())->addZhidu($params);
            ret_json('ok','ok',$list);
        }catch (\Exception $e){
            ret_json('err',$e->getMessage());
        }
    }
}
